package com.xinfu.newproject.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.xinfu.newproject.R;
import com.xinfu.newproject.adapter.paycost_provider.PayCostMultipleItemRvAdapter;
import com.xinfu.newproject.base.BaseActivity;
import com.xinfu.newproject.data.DataServer;
import com.xinfu.newproject.entity.MultipleItem;
import com.xinfu.newproject.entity.NormalMultipleEntity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PayCostActivity extends BaseActivity {

    private List<NormalMultipleEntity> mData;

    @BindView(R.id.activity_pay_cost_rv)
    RecyclerView mRecyclerView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_cost);
        ButterKnife.bind(this);
        setActivityTitle("缴费");
        registerBack();
        initViewBind();
        initLisener();
    }

    private void initLisener() {

    }

    private void initViewBind() {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mData = DataServer.getPayCostMultipleEntities();
        PayCostMultipleItemRvAdapter payCostMultipleItemRvAdapter = new PayCostMultipleItemRvAdapter(mData);

        payCostMultipleItemRvAdapter.setSpanSizeLookup(new BaseQuickAdapter.SpanSizeLookup() {
            @Override
            public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
                int type = mData.get(position).type;
                if (type == NormalMultipleEntity.TEXT_09) {
                    return MultipleItem.TEXT_SPAN_SIZE;
                } else if (type == NormalMultipleEntity.TEXT_10) {
                    return MultipleItem.IMG_SPAN_SIZE;
                } else {
                    return MultipleItem.IMG_TEXT_SPAN_SIZE;
                }
            }
        });


        mRecyclerView.setAdapter(payCostMultipleItemRvAdapter);
    }
}
